package com.liliudong.rommath.api.sys.controller;

import com.liliudong.rommath.biz.sys.param.SysUserAddParam;
import com.liliudong.rommath.biz.sys.param.SysUserPageParam;
import com.liliudong.rommath.biz.sys.result.SysUserPageResult;
import com.liliudong.rommath.biz.sys.service.SysUserService;
import com.liliudong.rommath.common.R;
import com.mybatisflex.core.paginate.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 系统用户 控制层。
 *
 * @author liudong.li
 * @since 1.0.0
 */
@RestController
@RequestMapping("/sys/user")
@RequiredArgsConstructor
public class SysUserController {

    private final SysUserService sysUserService;

    /**
     * 添加
     *
     * @param param 帕拉姆
     * @return {@link R }<{@link Void }>
     */
    @PostMapping
    public R<Void> add(@RequestBody @Validated SysUserAddParam param) {
        sysUserService.add(param);
        return R.ok();
    }


    /**
     * 页面
     *
     * @param param 帕拉姆
     * @return {@link R }<{@link Page }<{@link SysUserPageResult }>>
     */
    @GetMapping("/page")
    public R<Page<SysUserPageResult>> page(SysUserPageParam param) {
        Page<SysUserPageResult> page = sysUserService.queryPage(param);
        return R.ok(page);
    }

}